<%@page import="com.hotel.entity.olist"%>
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%@page import="java.util.ArrayList" %>
   <%@page import="java.util.List" %>
    <%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>订单详情</title>
	<link rel="stylesheet" href="../css/commit.css" type="text/css">
    <link rel="icon" href="../images/icon.jpg" type="image/x-icon">
    <link href="../css/bootstrap.css" rel="stylesheet" type="text/css">
      <link href="../css/orderdetails.css" rel="stylesheet" type="text/css">
    <link href="../css/bootstrapValidator.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="conntainer">
    <header id="box-head" class="clearfix">
        <!--导航-->
        <ul class="nav  navbar-nav fl">
            <li><img src="../images/logo.png" class="nav-img"></li>
            <li ><a href="index.jsp">首页</a></li>
            <li><a href="order.jsp">酒店预订</a></li>
            <li class="active"><a href="order.jsp">订单详情</a></li>
            <li ><a href="change.jsp">修改密码</a></li>
        </ul>
        <ul class=" nav fr navbar-top">
            <li class="fl">当前用户：<%=session.getAttribute("userName") %></li>
        </ul>      
    </header>
    <section>
    <%
    	try{
    		String driverName="com.mysql.jdbc.Driver";
    		String url="jdbc:mysql://localhost:3306/hotel";
    		String userName="root";
    		String passWord="root";
    		Class.forName(driverName);
    		Connection con=DriverManager.getConnection(url,userName,passWord);
    		String sql="select oid,oname,otime,ostatus from olist where oname=?;";
    		PreparedStatement ps=con.prepareStatement(sql);
    		ps.setString(1, session.getAttribute("userName").toString());
    		ResultSet rs=ps.executeQuery();
    		List<olist> list=new ArrayList<olist>();
    		while(rs.next()){
    			olist listOlist=new olist();
    			listOlist.setOid(rs.getInt(1));
    			listOlist.setOname(rs.getString(2));
    			listOlist.setOtime(rs.getString(3));
    			listOlist.setOstatus(rs.getString(4));
    			list.add(listOlist);
    		}
    		pageContext.setAttribute("mylist", list);
    	}catch(Exception e){
    		e.printStackTrace();
    	}
    	
    %>
    	
    	<table class="table table-striped tab">
 		 <thead>
   			<tr>
	    		<th>编号</th>
	    		<th>下订人</th>
	    		<th>提交时间</th>
	    		<th>状态</th>
    		</tr>
  		</thead>
  		<tbody>
  			 <c:forEach items="${pageScope.mylist }" var="obj">
    			<tr>	
    			<td >${obj.oid}</td>
				<td>${obj.oname}</td>
				<td>${obj.otime}</td>
				<td>${obj.ostatus}</td>
				</tr>
    		</c:forEach>
	  </tbody>
		</table>
    </section>
    </div>
  
</body>
</html>